<template>
  <div
    class="fy-sidebar"
    :class="{ 'hidden-sidebar': hiddenSidebar }"
  >
    <fy-logo></fy-logo>
    <div class="fy-sidebar-menu">
      <el-menu
        :default-active="activeMenu"
        :collapse="hiddenSidebar"
        :background-color="variables.defaultMenuBg"
        :text-color="variables.defaultMenuItemTextColor"
        :active-text-color="variables.defaultActiveTextColor"
        :unique-opened="false"
        :collapse-transition="false"
        mode="vertical"
      >
        <sidebar-item
          v-for="(route, i) in routes"
          :key="i"
          :item="route"
          :base-path="route.path"
        ></sidebar-item>
      </el-menu>
    </div>
    <div class="fy-sidebar-toggle">
      <div class="toggle" @click="toggle">
        <i v-if="hiddenSidebar" class="el-icon-arrow-right"></i>
        <i v-else class="el-icon-arrow-left"></i>
      </div>
    </div>
  </div>
</template>
<script>
import FyLogo from './logo.vue';
import { mapGetters } from 'vuex';
import SidebarItem from './sidebarItem';
import variables from '@/styles/variables.scss';

export default {
  name: '',
  components: {
    FyLogo,
    SidebarItem
  },
  data() {
    return {};
  },
  computed: {
    ...mapGetters(['routes', 'hiddenSidebar']),
    activeMenu() {
      const { meta, path } = this.$route;
      return meta.activeMenu || path;
    },
    variables() {
      return variables;
    }
  },
  created() {},
  mounted() {},
  methods: {
    toggle() {
      this.$store.dispatch('app/toggleSidebar', !this.hiddenSidebar);
    }
  }
};
</script>
<style lang="scss" scoped>

</style>
